package com.lots.mapper;

import com.lots.domain.entity.UserFavorite;
import lombok.Data;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserFavoriteMapper {
    /**
     * 查询收藏
     * @param currentUserId
     * @return
     */
    @Select("select count(*) from user_favorite where user_id = #{currentUserId} and dish_id = #{id}")
    int queryFavorite(Long currentUserId, Long id);
    /**
     * 添加收藏
     * @param userFavorite1
     */
    @Insert("insert into user_favorite(user_id,dish_id) values(#{userId},#{dishId})")
    void insertFavorite(UserFavorite userFavorite1);
    /**
     * 删除收藏
     * @param userId
     * @param dishId
     */
    @Delete("delete from user_favorite where user_id = #{userId} and dish_id = #{dishId}")
    void deleteFavorite(Long userId, Long dishId);
}
